package com.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.entity.EasyBuy_order_detail;

public class EasyBuy_order_detailDaoImpl extends BaseDao<EasyBuy_order_detail> implements Easybuy_order_detailDao {
	Connection conn = null;
	PreparedStatement ps = null;
	ResultSet rs = null;

	@Override
	public List<EasyBuy_order_detail> selectInfo(int id) {
		List<EasyBuy_order_detail> list = new ArrayList<EasyBuy_order_detail>();

		conn = getConnection();
		try {
			ps = conn.prepareStatement("SELECT * FROM easybuy_order_detail where orderId = ?");
			ps.setObject(1, id);
			rs = ps.executeQuery();

			while (rs.next()) {
				EasyBuy_order_detail order_detail = new EasyBuy_order_detail();
				order_detail.setId(rs.getInt("id"));
				order_detail.setOrderId(rs.getInt("orderId"));
				order_detail.setProductId(rs.getInt("productId"));
				order_detail.setQuantity(rs.getInt("quantity"));
				order_detail.setCost(rs.getFloat("cost"));
				list.add(order_detail);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			closeAll(conn, ps, rs);
		}
		return list;
	}

	@Override
	public String getTableName() {
		return "easybuy_order_detail";
	}

}
